﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ACAPM.Common;
using System.Configuration;

public partial class HTML_PrayerRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    private void ClearContactForm()
    {
        txtName.Text = string.Empty;
        txtAddress.Text = string.Empty;
        txtTelephone.Text = string.Empty;
        txtMobile.Text = string.Empty;
        txtEmail.Text = string.Empty;
        txtPrayerRequest.Text = string.Empty;
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblStatus.Visible = true;

        Email mail = new Email();
        string body = "<br/><h1>Prayer Request</h1><br/><b>From: </b>" + txtName.Text.Trim() + " (" + txtEmail.Text.Trim() + ") <br/><br/>" +
            "<b>Address: </b>" + txtAddress.Text.Trim() + "<br/><br/>" +
            "<b>Telephone #: </b>" + txtTelephone.Text.Trim() + "<br/><br/>" +
            "<b>Mobile #: </b>" + txtMobile.Text.Trim() + "<br/><br/>" +
            "<b>Email: </b>" + txtEmail.Text.Trim() + "<br/><br/>" +
            "<b>Prayer Request: </b>" + txtPrayerRequest.Text.Trim(); //Server.HtmlDecode(txtPrayerRequest.Text.Trim());
        mail.Subject = "Prayer request from " + txtName.Text;
        mail.Body = body;
        mail.ToAddress = ConfigurationManager.AppSettings["ToAddressPrayer"];

        if (EmailHelper.SendMail(mail))
        {
            divStatus.Attributes.Add("class", "notification success png_bg close");
            lblStatus.Text = "Your prayer request has been received. We will get back to you shortly.";

            ClearContactForm();

        }
        else
        {
            divStatus.Attributes.Add("class", "notification failure png_bg");
            lblStatus.Text = "There was an error in submitting your prayer request. Please try again later or call us at 91 44 26703685.";
        }
    }
}